from fasc_api.client.service_client import ServiceClient
from fasc_api.exception.exceptions import ClientException
from fasc_api.exception.exceptions import ServerException
from fasc_api.client.eui_client import EUIClient

from init_demo_data import InitDemoData
api_client = InitDemoData.api_client
access_token = ServiceClient.get_access_token_value(api_client)
api_client.set_access_token(access_token)



# 构造企业用户授权链接
def compose_corp_auth_url_demo():
    try:
        data = {
            'appId': api_client.app_id,            
            'openCorpId':'法大大平台为该企业在该应用appId范围内分配的唯一标识',
            # 授权范围串，逗号分隔。可以不设置，不设置则表示只申请账号绑定授权。
            'authScopes': 'ident_info,signtask_init,resource_for_sign',
            'corpName': '企业名称全称,可以不设置',
            'redirectUrl': '重定向地址,可以不设置'
        }
        res = EUIClient.compose_corp_auth_url(api_client, data)
        print(res)
    except ClientException as e:
        print(e.__str__())
    except ServerException as e:
        print(e.__str__())


if __name__ == '__main__':
    compose_corp_auth_url_demo()
